package client.gui;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * The Class LobbyGui
 * - Gui for WaitingLobby.
 */
public class LobbyGui extends JPanel{
	
	/** The universal version identifier. */
	private static final long serialVersionUID = -4967651859242386418L;
	
	/** The JFrame to which the lobbygui panel is added to.. */
	JFrame frame;
	
	/** The name of the player. */
	String name;
	
	/**
	 * Instantiates a new lobby gui.
	 *
	 * @param name the name of the player
	 */
	public LobbyGui(String name){
		this.name = name;
		run();
	}
	
	/**
	 * Run
	 * - Creates the gui.
	 */
	public void run(){
		frame = new JFrame("Lobby");
		frame.setSize(200, 80);
		frame.setResizable(false);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		JLabel lbl = new JLabel("Your name is: " + name, JLabel.CENTER);
		lbl.setVisible(true);
		JLabel lbl2 = new JLabel("Wait for other players to connect.", JLabel.CENTER);
		lbl2.setVisible(true);
		this.setLayout(new GridLayout(2, 1));
		frame.add(this);
		this.add(lbl);
		this.add(lbl2);
	}

	/**
	 * Dispose
	 * - Disposes the lobby gui JFrame.
	 */
	public void dispose() {
		frame.dispose();
	}
}
